<?php
namespace Admin\Controller;

class OrderController extends AdminController
{
	//订单首页
	public function index ()
	{
		if (!empty($_POST)) {
			/*var_dump($_POST); exit;*/
			$list = $_POST['date'];
			$data['date'] = array('like','%'.$list.'%'); 
			//var_dump($data);
			
			/*var_dump($data);exit;*/
			$count = M('orders')->where($data)->count();
			$page = new \Think\Page($count,8);
			$show = $page->show();
			$list = M('orders')->where($data)->limit($page->firstRow.','.$page->listRows)->select();
		} else {
			$count = M('orders')->count();
			$page = new \Think\Page($count,8);
			$show = $page->show();
			$list = M('orders')->field('lamp_orders.id,orderNumber,sid,phone,amount,time,lamp_orders.status,num')->join('lamp_user on lamp_orders.uid=lamp_user.id')->limit($page->firstRow.','.$page->listRows)->order('id asc')->select();
			//var_dump($list);exit;
		}
		//var_dump($data);exit;
		if (!$list){
			$this->assign ('row','暂无搜索内容...');
		}
		$this->assign ('list',$list);
		$this->display ();
	}
	//删除订单
	public function delete ()
	{
		$id = I ('get.id/d');
		if (M ('orders')->delete ($id) > 0) {
			$this->success ('删除成功',U('Order/index'));
		} else {
			$this->error ('删除失败');
		}
	}
}